<!DOCTYPE html>

<html>
    <head>
        <title>#{get 'title' /}</title>
        <meta http-equiv="Content-Type" content="text/html; charset=${_response_encoding}">
        <link rel="stylesheet" type="text/css" media="screen" href="@{'/public/stylesheets/main.css'}">
        #{get 'moreStyles' /}
        <link rel="shortcut icon" type="image/png" href="@{'/public/images/favicon.png'}">
        <script src="@{'/public/javascripts/jquery-1.3.2.min.js'}" type="text/javascript" charset="${_response_encoding}"></script>
        <script src="@{'/public/javascripts/sessvars.js'}" type="text/javascript" charset="${_response_encoding}"></script>
        <script src="@{'/public/javascripts/munichDeals.js'}" type="text/javascript" charset="${_response_encoding}"></script>
        <script type="text/javascript">
        function insertParam(key, value) {
            key = escape(key); value = escape(value);

            var kvp = document.location.search.substr(1).split('&');
            if (kvp == '') {
                document.location.search = '?' + key + '=' + value;
            }
            else {

                var i = kvp.length; var x; while (i--) {
                    x = kvp[i].split('=');

                    if (x[0] == key) {
                        x[1] = value;
                        kvp[i] = x.join('=');
                        break;
                    }
                }

                if (i < 0) { kvp[kvp.length] = [key, value].join('='); }

                //this will reload the page, it's likely better to store this until finished
                document.location.search = kvp.join('&');
            }
        }
        </script>
        #{get 'moreScripts' /}
    </head>
    <body  #{get 'moreOptions'/}>
        
        <div id="header">
            <a href="@{Application.index()}"><h1><img src="@{'/public/images/logo.png'}"></h1></a>
            #{if user?.id}
                <div id="options">
                	<a onclick="return insertParam('lang','en')" href="#" class="user" ><img src="@{'/public/images/en.png'}"></a>
                	<a onclick="return insertParam('lang','de')" href="#" class="user" ><img src="@{'/public/images/de.gif'}"></a>
                	|
                    <a href="#" class="user" >${user.username}</a>
                    |
                    <a href="@{Application.index()}">&{'application.home.text'}</a>
            	 	|
            	 	<a href="@{Deals.index()}">&{'application.deals.text'}</a>
            	 	|  
            	 	<a href="@{Application.myDeals()}">&{'application.mydeals.text'}</a>
            	 	|
                    <a href="@{Application.logout()}">&{'application.logout.text'}</a>
                </div>
            #{/if}
            #{else}
            	 <div id="options">
            	 	<a onclick="return insertParam('lang','en')" href="#"  class="user" ><img src="@{'/public/images/en.png'}"></a>
                	<a onclick="return insertParam('lang','de')" href="#"  class="user" ><img src="@{'/public/images/de.gif'}"></a>
                	|
            	 	<a href="@{Application.index()}">&{'application.home.text'}</a>            	 	
            	 	|
            	 	<a href="@{Deals.index()}">&{'application.deals.text'}</a>
            	 	| 
                    <a href="@{Application.myDeals()}">&{'application.login.text'}</a>
                    |
                    <a href="@{Application.register()}">&{'application.register.text'}</a>
                </div>
            #{/else}
        </div>
        
        <div id="content">

        	
        	
            #{if flash.error}
                <p class="fError">
                    <strong>${flash.error}</strong>
                </p>
            #{/if}
            #{if flash.success}
                <p class="fSuccess">
                    <strong>${flash.success}</strong>
                </p>
            #{/if}
            
            #{if !ignoreCategory}
            <div id="categories">
            	#{list items:categories, as:'category'}
            		#{if categoryId == category.id}
        				<a class="active" href="/deals/displayResults?categoryId=${category.id}">${category.categoryName}</a>
        			#{/if}
        			#{else}
        				<a href="/deals/displayResults?categoryId=${category.id}">${category.categoryName}</a>
        			#{/else}
        		#{/list}
        	</div>
        	#{/if}
            
            #{doLayout /}
        </div>
        
        <div id="footer">
           <a href="@{Application.company()}#about">&{'about.us.label'}</a> | <a href="@{Application.company()}#contact">&{'contact.us.label'}</a> | <a href="@{Application.company()}#faq">&{'faq.label'}</a>
        </div>
        
    </body>
</html>
